/**
 * 
 */
package com.archerdu.apply.service.impl;

import com.archerdu.apply.dao.ProductCatalogDAO;
import com.archerdu.apply.dao.ProductDAO;
import com.archerdu.apply.model.Product;
import com.archerdu.apply.model.ProductCatalog;
import com.archerdu.apply.service.ProductManager;
import com.archerdu.base.dao.IBaseDao;
import com.archerdu.base.service.BaseManager;

/**
 * @author archer
 * @version 1.0.0
 */
public class ProductManagerImpl extends BaseManager<Product, Integer> implements
        ProductManager {

    private static final long serialVersionUID = 8596375322783640728L;

    private ProductDAO productDao;
    private ProductCatalogDAO    productCatalogDao;

    @Override
    public void add(Product entity) throws Exception {
        ProductCatalog cate = productCatalogDao.get(entity.getCatalogId());
        entity.setCatalogCode(cate.getCode());
        entity.setCreatetime(getSqlDate());
        
        super.add(entity);
    }

    public void setProductDao(ProductDAO dao) {
        productDao = dao;
    }

    public ProductDAO getProductDao() {
        return productDao;
    }

    @Override
    protected IBaseDao<Product, Integer> getDao() {
        return (IBaseDao<Product, Integer>) productDao;
    }

    public ProductCatalogDAO getProductCatalogDao() {
        return productCatalogDao;
    }

    public void setProductCatalogDao(ProductCatalogDAO productCatalogDao) {
        this.productCatalogDao = productCatalogDao;
    }
}
